// @ts-ignore
const path = require('path');
// @ts-ignore
import {defineConfig} from 'vite';
// @ts-ignore
import vue from '@vitejs/plugin-vue';
// @ts-ignore
import DefineOptions from 'unplugin-vue-define-options/vite';
import OptimizationPersist from 'vite-plugin-optimize-persist'
import PkgConfig from 'vite-plugin-package-config'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import {ElementPlusResolver} from 'unplugin-vue-components/resolvers'
// https://vitejs.dev/config/
export default defineConfig({
    plugins: [
        PkgConfig(),
        OptimizationPersist(),
        DefineOptions(),
        vue(),
        AutoImport({
            resolvers: [ElementPlusResolver()],
        }),
        Components({
            resolvers: [ElementPlusResolver()],
        })],
    optimizeDeps: {
        include: [
            "element-plus/es",
            "element-plus/es/components/config-provider/style/css",
            "element-plus/es/components/container/style/css",
            "element-plus/es/components/main/style/css",
            "element-plus/es/components/header/style/css",
            "element-plus/es/components/date-picker/style/css",
            "element-plus/es/components/drawer/style/css",
            "element-plus/es/components/image/style/css",
            "element-plus/es/components/image/style/css",
            "element-plus/es/components/table/style/css",
            "element-plus/es/components/table-column/style/css",
            "element-plus/es/components/input/style/css",
            "element-plus/es/components/dropdown/style/css",
            "element-plus/es/components/popover/style/css",
            "element-plus/es/components/dropdown-item/style/css",
            "element-plus/es/components/dropdown-menu/style/css",
            "element-plus/es/components/pagination/style/css",
            "element-plus/es/components/scrollbar/style/css",
            "element-plus/es/components/dialog/style/css",
            "element-plus/es/components/loading/style/css",
            "element-plus/es/components/tabs/style/css",
            "element-plus/es/components/tab-pane/style/css",
            "element-plus/es/components/select/style/css",
            "element-plus/es/components/option/style/css",
            "vue",
            "less",
            "vue-router"
        ],
    },
    resolve: {
        // 配置路径别名
        alias: {
            // @ts-ignore
            '@': path.resolve(__dirname, './src'),
        },
    },
    server: {
        proxy: {
            "/api": {
                target: "http://127.0.0.1:9501",
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, '') // 路径重写，本项目不需要重写
            },
            "/geoMap": {
                target: "http://192.168.1.5:11345/",
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/geoMap/, '') // 路径重写，本项目不需要重写
            },
            "/screen": {
                target: "http://127.0.0.1:8080",
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/screen/, '') // 路径重写，本项目不需要重写
            },
        }
    }
});
